package org.huntaway.issist;

import java.util.Iterator;

import org.dom4j.Document;
import org.dom4j.Element;
import org.huntaway.material.cleaner.base.bean.CommonTagBean;
import org.huntaway.material.cleaner.manager.model.imp.ConfigManager;

public class BuildJava {
	ConfigManager configManager = new ConfigManager();

	public static void main(String argv[]) {
		BuildJava bj = new BuildJava();
		bj.buildjava();
	}

	private void buildjava() {
		Document document = configManager.getTagDocument();
		Element root = document.getRootElement();
		StringBuffer sb = new StringBuffer();
		sb.append("通过Dom4j解析XML,并输出数据:\n");
		sb.append("----------------遍历start----------------\n");
		// 遍历当前元素(在此是根元素)的子元素
		for (Iterator<Element> i_pe = root.elementIterator(); i_pe.hasNext();) {
			Element e_pe = (Element) i_pe.next();
			for (int i = 0; i < e_pe.attributes().size(); i++) {

			}
			for (int i = 0; i < e_pe.elements().size(); i++) {

			}
			String name = e_pe.attributeValue("name");
			Element ele_dist = e_pe.element("dest");
			String dist = ele_dist == null ? "" : ele_dist.getText();
			sb.append("\t\t" + name + ":" + " dist=" + dist + " value=\""
					+ name + "\"\n");
		}
		sb.append("-----------------遍历end-----------------\n");
		System.out.println(sb.toString());
	}
}
